<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<meta content="text/html;charset=UTF-8"/>
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
	<meta http-equiv ="Pragma" content = "no-cache"/>
	<meta http-equiv="Cache-Control" content="no cache" />
	<meta http-equiv="Expires" content="0" />
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
	<meta name="apple-mobile-web-app-status-bar-style" content="black"/>
	<meta name="apple-mobile-web-app-capable" content="yes"/>
	<meta name="format-detection" content="telephone=no"/>
	<script src="https://cdn.bootcss.com/pace/1.0.2/pace.min.js"></script>
	<link href="https://cdn.bootcss.com/pace/1.0.2/themes/pink/pace-theme-flash.css" rel="stylesheet">
	<link rel="stylesheet" type="text/css" href="/static/fsLayui-1.8.2/plugins/layui/css/layui.css" media="all"/>
	<link rel="stylesheet" type="text/css" href="/static/fsLayui-1.8.2/css/fs.css" media="all"/>
	<script type="text/javascript" src="/static/fsLayui-1.8.2/plugins/layui/layui.js"></script>
	<script type="text/javascript" src="/static/fsLayui-1.8.2/plugins/jquery/jquery.min.js"></script>
	<script type="text/javascript" src="/static/fsLayui-1.8.2/plugins/frame/js/fsDict.js?v=1.5.0"></script>
	<script type="text/javascript" src="/static/fsLayui-1.8.2/plugins/frame/js/fs.js?v=1.5.0"></script>
	<script type="text/javascript" src="/static/fsLayui-1.8.2/plugins/frame/js/frame.js?v=1.5.0"></script>
</head>
<body>
   <div class="layui-fluid">
  <div class="layui-row layui-col-space1">
  	  	 <div class="blog-main-left animated slideInLeft">
          <div class="flow-default">
             <form class="layui-form" id="edit_form" loadUrl="/admin/save">
    <input type="hidden" name="adminId" th:value="${user.adminId}"/>
    <div class="layui-form-item" style="width: 800px;">
      <label class="layui-form-label">用户名</label>
      <div class="layui-input-block">
        <input type="text" name="userName" required="" lay-verType="tips" lay-verify="required" th:value="${user.userName}"  autocomplete="off" class="layui-input" />
      </div>
    </div>
    <div class="layui-form-item" style="width: 800px;">
      <label class="layui-form-label">真实姓名</label>
      <div class="layui-input-block">
        <input type="text" name="trueName" required="" lay-verType="tips" th:value="${user.trueName}" lay-verify="required"  autocomplete="off" class="layui-input"/>
      </div>
    </div>
    <div class="layui-form-item" style="width: 800px;">
      <label class="layui-form-label">密码</label>
      <div class="layui-input-block">
        <input type="text" name="password" required="" lay-verType="tips" lay-verify="required"  th:value="${user.password}" autocomplete="off" class="layui-input"/>
      </div>
    </div>
    
    <div class="layui-form-item" style="width: 800px;">
      <label class="layui-form-label">电话</label>
      <div class="layui-input-block">
        <input type="text" name="phone" required="" lay-verType="tips" lay-verify="required"  th:value="${user.phone}" autocomplete="off" class="layui-input"/>
      </div>
    </div>
    
    
    
    <div class="layui-form-item" style="width: 800px;">
      <label class="layui-form-label">性别</label>
      <div class="layui-input-block">
        <input type="text" name="sex" required="" lay-verType="tips" th:value="${user.sex}" lay-verify="required"  autocomplete="off" class="layui-input"/>
      </div>
    </div>
    
     <div class="layui-form-item" style="width: 800px;">
      <label class="layui-form-label">备注</label>
      <div class="layui-input-block">
        <input type="text" name="signature" required="" lay-verType="tips" th:value="${user.signature}" lay-verify="required"  autocomplete="off" class="layui-input"/>
      </div>
    </div>
    
    <div class="layui-form-item">
      <label class="layui-form-label">头像</label>
    <div class="layui-upload">
      <button type="button" class="layui-btn" id="test1">上传图片</button>
      <div class="layui-upload-list">
        <p id="demoText"></p>
      </div>
    </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label"></label>
      <div class="layui-input-block">
        <img class="layui-upload-img" id="demo1" name="headPortrait" style="width: 250px;height: 150px;" />
      </div>
    </div>
    <input type="hidden" id="headPortrait" name="headPortrait" th:value="${user.headPortrait}"/>
    <hr/>
    <div class="layui-form-item" style="margin-left: 100px;">
    <button class="layui-btn" lay-submit="" url="/admin/save">保存</button>
    </div>
</form>
          </div>
        </div>
  

  </div>
</div>
<script>
layui.use('upload', function(){
  var $ = layui.jquery
  ,upload = layui.upload;
  
  //普通图片上传
  var uploadInst = upload.render({
    elem: '#test1'
    ,url: '/upload'
    ,before: function(obj){
      //预读本地文件示例，不支持ie8
      obj.preview(function(index, file, result){
        $('#demo1').attr('src', result); //图片链接（base64）
      });
    }
    ,done: function(res){
      //如果上传失败
      if(res.code > 0){
        return layer.msg('上传失败');
      }
      $('#headPortrait').val(res.data.filePath); //图片链接（base64）
      //上传成功
    }
    ,error: function(){
      //演示失败状态，并实现重传
      var demoText = $('#demoText');
      demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
      demoText.find('.demo-reload').on('click', function(){
        uploadInst.upload();
      });
    }
  });
});

$(window).load(function(){
  setTimeout(images, 200);
});
function images(){
  var str=$('#headPortrait').val();
   $("#demo1").attr("src","/static/images/"+str);
}
</script>
</body>
</html>
